%% Common postScript header.

/boxHere {
% Draw a box at current position.
% Usage width height boxAt
dup 0 exch   %stack width height 0 height
rlineto      %stack width height
exch dup 0   %stack height width width 0
rlineto      %stack height width
exch         %stack width height
0 exch       %stack width 0 height
neg          %stack width 0 -height
rlineto      %stack width
neg 0        %stack -width 0
rlineto
} def

/boxAt {
% Draw a box at a position.  Usage:
% width height x y boxAt
moveto
boxHere
} def

/fillBox {
% Draw filled box at a position. Usage:
% width height x y fillBox
newpath
boxAt
fill
} def

/strokeBox {
% Draw stroked box at a position. Usage:
% width height x y strokeBox
newpath
boxAt
stroke
} def

/smallFont {
/Times-Roman findfont
10 scalefont
setfont
} def

/showBefore {
% Draw text immediately before rather
% than immediately after current position.
% Usage (some text) showBefore
dup
stringwidth
neg
exch
neg
exch
rmoveto
show
} def

/showMiddle {
% Draw text centered at current position.
% Usage (some text) showMiddle
dup stringwidth
2 div neg
exch
2 div neg
exch
rmoveto
show
} def

/ellipse {
/endangle exch def
/startangle exch def
/yrad exch def
/xrad exch def
/y exch def
/x exch def
/savematrix matrix currentmatrix def
x y translate
xrad yrad scale
0 0 1 startangle endangle arc
savematrix setmatrix
} def

/fillTextBox {
true charpath pathbbox
/y2 exch def /x2 exch def
/y1 exch def /x1 exch def
/w x2 x1 sub def
/h y2 y1 sub def
w h x1 y1 fillBox
} def

smallFont

